# The American Viewer: Political Consequences of Entertainment Media
# Eunji Kim and Shawn Patterson Jr 
# American Political Science Review 
# Replication File [Appendix K Table K1 and K2]



appendix_tablek <- read.csv("appendix_tablek_censored.csv")

# Table K1 # 

pri12_romney <- felm(romney_share_primary12  ~ mccainshare08_new + 
                       log(population_04 +1) +
                       log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                       collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census  + religion_allP + 
                       log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                       STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                     data = appendix_tablek, weights=appendix_tablek$sum_CNTYTVHH) 

pri12_santorum <- felm(santorum_share_primary12~   mccainshare08_new + 
                         log(population_04 +1) +
                         log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                         collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP + 
                         log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                         STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                       data = appendix_tablek, weights=appendix_tablek$sum_CNTYTVHH) 

pri12_gingrich <- felm(gingrich_share_primary12  ~  mccainshare08_new + 
                         log(population_04 +1) +
                         log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                         collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP + 
                         log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                         STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                       data = appendix_tablek, weights=appendix_tablek$sum_CNTYTVHH) 

pri12_paul <- felm(paul_share_primary12  ~  mccainshare08_new + 
                     log(population_04 +1) +
                     log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                     collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP + 
                     log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                     STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                   data = appendix_tablek, weights=appendix_tablek$sum_CNTYTVHH) 



stargazer(pri12_romney, pri12_santorum, pri12_gingrich, pri12_paul, 
          star.cutoffs = c(0.1, .05,.01,.001),
          title="(No) Apprentice Effect on 2012 Republican Primary Candidates",
          dep.var.caption = "",
          dep.var.labels=c('Romney Share 12', 
                           'Santorum Share 12',
                           'Gingrich Share 12',
                           'Paul Share 12'),
          omit.stat=c("adj.rsq","LL","ser","f"),
          no.space=TRUE,
          omit = c("STATE"),
          star.char = c("+", "*", "**", "***"), 
          notes = c("*p<0.1, * p<0.05; ** p<0.01; *** p<0.001"), 
          notes.append = F,
          notes.align="l",
          digits=3,
          type ="text",
          align = TRUE)


# Table K2 # 


pri08_paul <- felm(paul_share_primary08 ~ bushshare04_new + 
                     log(population_04 +1) +
                     log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                     collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP + 
                     log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                     STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                   data = appendix_tablek, weights=appendix_tablek$sum_CNTYTVHH) 


pri08_huckabee <- felm(huckabee_share_primary08 ~  bushshare04_new + 
                         log(population_04 +1) +
                         log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                         collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP + 
                         log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                         STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                       data = appendix_tablek, weights=appendix_tablek$sum_CNTYTVHH) 


pri08_romney <- felm(romney_share_pimary08  ~ bushshare04_new + 
                       log(population_04 +1) +
                       log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                       collegeP_04 + foreignBP_04 + unemR_04    +  samesex_census   + religion_allP +
                       log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                       STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                     data = appendix_tablek, weights=appendix_tablek$sum_CNTYTVHH) 


pri08_mccain <- felm(mccain_share_pimary08  ~ bushshare04_new + 
                       log(population_04 +1) +
                       log(medianHHI_04+1) + femaleP_04 + age65P_04 + whiteP_04 + blackP_04  +
                       collegeP_04 + foreignBP_04 + unemR_04  +  samesex_census  + religion_allP + 
                       log(avg_outflow_movers + 1) + log(avg_inflow_movers + 1 ) + pop_density.x  | 
                       STATE  | (RTG_9PM_Nov_May  ~ RTG_8PM_Nov_May) | 0 , 
                     data = appendix_tablek, weights=appendix_tablek$sum_CNTYTVHH) 


stargazer(pri08_huckabee, pri08_paul, pri08_romney, pri08_mccain,  
                                   star.cutoffs = c(0.1, .05,.01,.001),
                                   title="(No) Appentice Effect on 2008 Republican Primary Candidates",
                                   dep.var.caption = "",
                                   dep.var.labels=c('Huckabee Share', 
                                                    'Paul Share', 'Romney Share', 'McCain Share'),
                                   omit.stat=c("adj.rsq","LL","ser","f"),
                                   no.space=TRUE,
                                   omit = 'STATE',
                                   star.char = c("+", "*", "**", "***"), 
                                   notes = c("+ p<0.10; * p<0.05; ** p<0.01; *** p<0.001"), 
                                   notes.append = F,
                                   notes.align="l",
                                   digits=3,
                                  type= 'text',
                                   align = TRUE)



